<!--
 * @Author: anshengtyp
 * @Date: 2023-11-27 15:35:47
 * @LastEditTime: 2023-11-27 15:38:40
 * @LastEditors: anshengtyp
 * @Description:
-->
<template>
  <el-select v-model="select" :multiple="multiple" placeholder="请选择" style="width: 100%;" :disabled="disabled"
    size="small" :filterable="isFilterable" @change="handleChange">
    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
    </el-option>
  </el-select>
</template>

<script>
import { getAllUserList } from "@/api/system/user";

export default {
  props: {
    value: {
      type: String | Array,
      require
    },
    multiple: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    isFilterable: { // 是否支持搜索
      type: Boolean,
      default: true
    },
  },
  data() {
    return {
      select: null,
      options: []
    };
  },
  created() {
    this.getData();
  },
  watch: {
    value: {
      immediate: true,
      handler(n) {
        this.select = n;
      }
    },
  },
  methods: {
    async getData() {
      const res = await getAllUserList();
      if (res.code === 200) {
        this.options = res.data
      }
    },
    // 改变
    handleChange(value) {
      this.$emit('input', value);
      this.$emit('change', value);
    },
  }
}
</script>

<style lang="sass" scoped>

</style>
